Embassy Notes

2024-06-11

最后编辑于:2024-06-29

    #async

Async Rust in Embedded Systems with Embassy - Dario Nieuwenhuis

Youtube Github repo

预先静态分配任务,使用链表组织任务队列 可以参考#[embassy_excutor::task]的设计

通常的实现 ![[assets/截屏2024-06-11 21.54.42.png]] then(OS epoll driven)

loop {
	Poll Woken tasks
	Wait on epoll() with FDs fron Reactor
	Wake tasks with FDs that became ready
}

But

  • can't use alloc
  • must avoid dangling pointers from wakers
  • no OS

=> So statically allocate tasks ![[assets/截屏2024-06-11 21.59.39.png]] Use an intrusive linked list

![[assets/截屏2024-06-11 22.03.11.png]] 这里my_task不返回FutureSpawnToken是指向已初始化任务的指针

![[assets/截屏2024-06-11 23.01.44.png]]

中断驱动任务运行 ![[assets/截屏2024-06-11 23.02.12.png]]

No reactor!

![[assets/截屏2024-06-11 23.07.52.png]]Current solution: Just don't do that :)